package android07.newtop.holder;

import android.support.v7.widget.CardView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;

import android07.newtop.R;
import android07.newtop.model.bean.WeatherInfoBean;


/**

 *
 */
public class SuggestionViewHolder extends BaseViewHolder<WeatherInfoBean.ResultBean.DataBean.LifeBean> {


    private static final String TAG = SuggestionViewHolder.class.getSimpleName();
    private ImageView weathericon;
    private TextView tempflu;
    private TextView tempmax;
    private TextView tempmin;
    private LinearLayout templayout;
    private LinearLayout lineartemp;
    private TextView temppm;
    private TextView tempquality;
    private CardView cardView;
    private TextView clothbrief;
    private TextView clothtxt;
    private TextView sportbrief;
    private TextView sporttxt;
    private TextView travelbrief;
    private TextView traveltxt;
    private TextView flubrief;
    private TextView flutxt;

    public SuggestionViewHolder(ViewGroup parent) {
        super(parent, R.layout.item_suggestion);

        //此行代码是为了 一键findviewby而书写  非常爽！！！！
       // View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_suggestion, null);
        this.cardView = (CardView) itemView.findViewById(R.id.cardView);
        this.flutxt = (TextView) itemView.findViewById(R.id.flu_txt);
        this.flubrief = (TextView) itemView.findViewById(R.id.flu_brief);
        this.traveltxt = (TextView) itemView.findViewById(R.id.travel_txt);
        this.travelbrief = (TextView) itemView.findViewById(R.id.travel_brief);
        this.sporttxt = (TextView) itemView.findViewById(R.id.sport_txt);
        this.sportbrief = (TextView) itemView.findViewById(R.id.sport_brief);
        this.clothtxt = (TextView) itemView.findViewById(R.id.cloth_txt);
        this.clothbrief = (TextView) itemView.findViewById(R.id.cloth_brief);


    }


    /**
     * 这里是数据设置的方法，非常简单，面向对象编程
     * <p>
     * 当数据成功获取，并且填充到Adpter这里可以设置每个item的数据
     *
     * @param data
     */
    @Override
    public void setData(WeatherInfoBean.ResultBean.DataBean.LifeBean data) {
        super.setData(data);

        try {

            clothbrief.setText(String.format("穿衣指数---%s", data.getInfo().getChuanyi().get(0)));
            clothtxt.setText(data.getInfo().getChuanyi().get(1));

                sportbrief.setText(String.format("运动指数---%s", data.getInfo().getYundong().get(0)));
            sporttxt.setText(data.getInfo().getYundong().get(1));

                travelbrief.setText(String.format("洗车指数---%s", data.getInfo().getXiche().get(0)));
                traveltxt.setText(data.getInfo().getXiche().get(1));

            flubrief.setText(String.format("感冒指数---%s", data.getInfo().getGanmao().get(0)));
            flutxt.setText(data.getInfo().getGanmao().get(1));
            } catch (Exception e) {
                Log.e(TAG,e.toString());
            }

    }
}
